package com.kj.tms.system.controller.menu;


import com.kj.tms.common.bean.dto.ReturnData;
import com.kj.tms.pri.system.menu.dto.DataSourceDTO;
import com.kj.tms.pri.system.menu.service.DataSourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@SuppressWarnings("rawtypes")
@Controller
@RequestMapping("/system/ds")
public class DataSourceController {
    private static final Logger logger = LoggerFactory.getLogger(DataSourceController.class);
    @Autowired
    private DataSourceService dataSourceService;

    /**
     * 数据源首页
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("/index")
    public String index() throws Exception {
        return "system/dataSource/index";
    }

    @RequestMapping("/toAdd")
    public String toAdd() {
        return "system/dataSource/add";
    }

    @RequestMapping("/toUpdate")
    public String toUpdate() {
        return "system/dataSource/update";
    }

    @RequestMapping("/queryByPage")
    @ResponseBody
    public ReturnData queryByPage(DataSourceDTO model) {
        ReturnData returnData = dataSourceService.queryByPageInfo(model);
        return returnData;
    }

    @RequestMapping("/getDataSource")
    @ResponseBody
    public ReturnData getDataSource(DataSourceDTO model) {
        ReturnData returnData = dataSourceService.getByCondition(model);
        return returnData;
    }

    @RequestMapping("/save")
    @ResponseBody
    public ReturnData save(DataSourceDTO dto) {
       ReturnData returnData =dataSourceService.save(dto);
        return returnData;
    }

    @RequestMapping("/update")
    @ResponseBody
    public ReturnData update(DataSourceDTO dto) {
        ReturnData returnData =dataSourceService.update(dto);
        return returnData;
    }

    @RequestMapping("/delete")
    @ResponseBody
    public ReturnData delete(DataSourceDTO dto) {
        ReturnData returnData =dataSourceService.delete(dto);
        return returnData;
    }
}
